﻿Public Class fArea 

    Private Sub AreaBindingNavigatorSaveItem_Click(sender As System.Object, e As System.EventArgs) Handles AreaBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.AreaBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.DbSolucionesEducativasDataSet)

    End Sub

    Private Sub fArea_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'DbSolucionesEducativasDataSet.area' table. You can move, or remove it, as needed.
        Me.AreaTableAdapter.Fill(Me.DbSolucionesEducativasDataSet.area)

    End Sub

    Private Sub SimpleButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles agregar.Click
        BindingNavigatorAddNewItem.PerformClick()
        Habilitar()
    End Sub

    Function Habilitar()
        AredescripcionTextBox.ReadOnly = False
        AreobservacionTextBox.ReadOnly = False
        Return 0
    End Function

    Function DesHabilitar()
        AredescripcionTextBox.ReadOnly = True
        AreobservacionTextBox.ReadOnly = True
        Return 0
    End Function

    Private Sub SimpleButton4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles guardar.Click
        AreaBindingNavigatorSaveItem.PerformClick()
        DesHabilitar()
    End Sub

    Private Sub SimpleButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles modificar.Click
        Habilitar()
    End Sub

    Private Sub SimpleButton5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cancelar.Click
        DesHabilitar()
        Me.AreaTableAdapter.Fill(Me.DbSolucionesEducativasDataSet.area)
    End Sub

    Private Sub SimpleButton6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles imprimir.Click
        ' Check whether the GridControl can be previewed.
        If Not GridControl1.IsPrintingAvailable Then
            MessageBox.Show("Error al intentar imprimir el reporte, contacte el administrador del sistema.", "Error")
            Return
        End If

        ' Opens the Preview window.
        GridControl1.ShowPrintPreview()
    End Sub
End Class